package com.yndsoft.jc.ui.shoppingcart;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.CheckBox;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.yndsoft.jc.R;
import com.yndsoft.jc.activity.BaseActivity;
import com.yndsoft.jc.supplier.utils.ToastUtil;
import com.yndsoft.jc.utils.ConstantValues;

import butterknife.Bind;

/**
 * Created by hasee on 2017/12/5.
 */

public class PayForOrderActivity extends BaseActivity implements View.OnClickListener {

    @Bind(R.id.base_backBtn)
    RelativeLayout base_backBtn;
    @Bind(R.id.base_title)
    TextView base_title;

    @Bind(R.id.order_pay_totalproce)
    TextView order_pay_totalproce;
    @Bind(R.id.rl_alipay)
    RelativeLayout rl_alipay;
    @Bind(R.id.cb_alipay)
    CheckBox cb_alipay;
    @Bind(R.id.rl_wechat)
    RelativeLayout rl_wechat;
    @Bind(R.id.cb_wechat)
    CheckBox cb_wechat;
    @Bind(R.id.rl_unionpay)
    RelativeLayout rl_unionpay;
    @Bind(R.id.cb_unionpay)
    CheckBox cb_unionpay;

    @Bind(R.id.go_to_pay_btn)
    Button go_to_pay_btn;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_pay_for_order);

        setViews();
        setListener();
    }

    private void setViews() {
        base_title.setText(getResources().getString(R.string.order_pay));
        order_pay_totalproce.setText("￥" + getIntent().getDoubleExtra(ConstantValues.CONFIRM_ORDER, 0.00));
    }

    private void setListener() {
        base_backBtn.setOnClickListener(this);
        go_to_pay_btn.setOnClickListener(this);
        rl_alipay.setOnClickListener(this);
        rl_wechat.setOnClickListener(this);
        rl_unionpay.setOnClickListener(this);
    }

    @Override
    public void onClick(View view) {
        Intent intent = null;
        switch (view.getId()) {
            case R.id.base_backBtn:
                finish();
                break;
            case R.id.rl_alipay:
                cb_alipay.setChecked(true);
                cb_wechat.setChecked(false);
                cb_unionpay.setChecked(false);
                break;
            case R.id.rl_wechat:
                cb_alipay.setChecked(false);
                cb_wechat.setChecked(true);
                cb_unionpay.setChecked(false);
                break;
            case R.id.rl_unionpay:
                cb_alipay.setChecked(false);
                cb_wechat.setChecked(false);
                cb_unionpay.setChecked(true);
                break;
            case R.id.go_to_pay_btn:
                if (cb_alipay.isChecked()) {
                    ToastUtil.show(mContext, "支付方式为：------支付宝");
                } else if (cb_wechat.isChecked()) {
                    ToastUtil.show(mContext, "支付方式为：------微信");
                } else if (cb_unionpay.isChecked()) {
                    ToastUtil.show(mContext, "支付方式为：------银联");
                } else {
                    ToastUtil.show(mContext, "请选择支付方式");
                }
                intent = new Intent(this, PaySuccessfulActivity.class);
                startActivity(intent);
                break;
        }
    }
}
